﻿using Shop.RemoteModel.SpecGroupTemplate.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/spec/group/template/{name}")]
    internal class SpecGroupTemplateApi : ApiController
    {
        private readonly ISpecGroupTService _Service;

        public SpecGroupTemplateApi (ISpecGroupTService service)
        {
            this._Service = service;
        }
        /// <summary>
        /// 设置分类的排序位
        /// </summary>
        /// <param name="param"></param>
        public Dictionary<long, int> SetSort (LongParam<int> param)
        {
            return this._Service.SetSort(param.Id, param.Value);
        }
        /// <summary>
        /// 获取规格摸版项
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public SpecGroupTItem[] GetItems ([NumValidate("shop.category.id.error", 1)] long categoryId)
        {
            return this._Service.GetItems(categoryId);
        }

        public long Add (SpecGroupTSet datum)
        {
            return this._Service.Add(datum);
        }

        public void Delete ([NumValidate("shop.spec.group.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }

        public SpecGroupT Get ([NumValidate("shop.spec.group.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }

        public SpecGroupTDto[] Gets ([NumValidate("shop.category.id.error", 1)] long categoryId)
        {
            return this._Service.Gets(categoryId);
        }

        public bool Set (LongParam<SpecGroupTSet> param)
        {
            return this._Service.Set(param.Id, param.Value);
        }

        public void SetIsEnable (LongParam<bool> param)
        {
            this._Service.SetIsEnable(param.Id, param.Value);
        }
    }
}
